package com.tfswx.jcyw.ruleenginedesigner.api;

import com.tfswx.jcyw.ruleenginedesigner.bean.ApiResult;
import com.tfswx.jcyw.ruleenginedesigner.dto.ffgl.FfSaveInputDTO;
import com.tfswx.jcyw.ruleenginedesigner.service.FfService;
import com.tfswx.ruleengine.compute.gzjy.BaseFn;
import com.tfswx.ruleengine.compute.gzjy.RuleEngineUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ricky
 * @date 2021/8/31
 */
@RequestMapping("ffgl")
@Api(tags = "方法")
@RestController
public class FfglController {
    @Resource
    private FfService ffService;

    @ApiOperation("获取方法")
    @PostMapping("getFnList")
    public ApiResult<List<BaseFn>> getFnList() {
        List<BaseFn> fnList = RuleEngineUtil.getFnList();
        return ApiResult.success(fnList);
    }

    @ApiOperation("添加方法")
    @PostMapping("saveFf")
    public ApiResult<Boolean> getFnList(@RequestBody @Validated FfSaveInputDTO inputDTO) {
        boolean isSucc = ffService.saveFf(inputDTO);
        return ApiResult.success(isSucc);
    }
}
